package com.ld.controller;

import com.ld.common.ResultInfoFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MainController {

    @Autowired
    private OAuth2RestTemplate oAuth2RestTemplate;

    @RequestMapping("/")
    public String index(){
        return "index";
    }

    @RequestMapping("/member")
    public String menber(){
        return "member";
    }
    @RequestMapping("/getProductList")
    @ResponseBody
    public ResultInfoFactory getProductList(){
        ResponseEntity<ResultInfoFactory> forEntity = oAuth2RestTemplate.getForEntity
                ("http://127.0.0.1:7001/product/product/list", ResultInfoFactory.class);
        ResultInfoFactory body = forEntity.getBody();
        return body;
    }

}
